<% layout('/layouts/default.html', {title: '审核管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa fa-list-alt"></i> ${text('审核管理')}
			</div>
			<div class="box-tools pull-right">
				<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
			</div>
		</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${record}" action="${ctx}/vip/record/listData" method="post" class="form-inline hide"
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
				<div class="form-group" >
					<label class="control-label">${text('类型')}：</label>
					<div class="control-inline" style="width:80px;" >
						<#form:select path="type" dictType="vip_record_type" blankOption="true" class="form-control required" />
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('会员')}：</label>
					<div class="control-inline">
						<#form:input path="memberId" maxlength="32" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group"  >
					<label class="control-label">${text('审核状态')}：</label>
					<div class="control-inline" style="width:150px;">
						<#form:select path="reviewerState" dictType="vip_review_state"  id="typeId" class="form-control required" />
					</div>
				</div>
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
				</div>
			</#form:form>
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>
// 初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: [
		{header:'${text('类型')}', name:'type', index:'a.type', width:80, align:"center", frozen:true, formatter: function(val, obj, row, act){
                return js.getDictLabel(${@DictUtils.getDictListJson('vip_record_type')}, val, '未知', true);
		}},
        {header:'${text('代理人/会员')}', name:'agentUser.userName', sortable:false, width:120, align:"center", frozen:true, formatter: function(val, obj, row, act){
                var str = "<span>代理："+val+"</span></br>"+ "<span>会员："+row.member.name+"</span>";
            	return str;
            }},
		{header:'${text('金额')}', name:'money', index:'a.money', width:80, align:"center", formatter: function(val, obj, row, act){
                return formatNumber(val); // 数值类型格式化 (原始数值, 小数位数, 是否千分位, 默认值，金额情况下设置0.00);
		}},
        {header:'${text('项目')}', name:'project.name', index:'p.name', width:80, align:"center",formatter:function (val, obj, row, act) {
                return (val == '' || val == undefined) ? '--' : val;
            }},
        {header:'${text('审核状态')}', name:'reviewerState', index:'a.reviewer_state', width:80, align:"center", frozen:true, formatter: function(val, obj, row, act){
                return js.getDictLabel(${@DictUtils.getDictListJson('vip_review_state')}, val, '未知', true);
            }},
		{header:'${text('时间')}', name:'createDate', index:'a.create_date', width:150, align:"center"},
		{header:'${text('操作')}', name:'actions', align:"center", width:80, sortable:false, title:false, formatter: function(val, obj, row, act){
			var actions = [];
            <% if(hasRoles('1000')){ %>
                    if(row.reviewerState == '0'){//系统管理员可以审核任意类型
                        actions.push('<a href="#" onclick="checkClick(\''+row.id+'\');" class="btn btn-primary label-success">审核</a>');
                    }
            <% } %>
			<% if(hasRoles('1006')){ %>
					if(row.reviewerState == '0' && (row.type =='1' || row.type =='2') ){//审核员审核出货入货
			    		actions.push('<a href="#" onclick="checkClick(\''+row.id+'\');" class="btn btn-primary label-success">审核</a>');
					}
			<% } %>
            <% if(hasRoles('1004')){ %>
                    if(row.reviewerState == '0' && (row.type =='3' || row.type =='4') ){//财务审核充值和结账
                        actions.push('<a href="#" onclick="checkClick(\''+row.id+'\');" class="btn btn-primary label-success">审核</a>');
                    }
             <% } %>
			return actions.join('');
		}}
	],
    showRownum: false,
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
function checkClick(id){
    js.layer.open({
        type: 1,
        area: ['300px','300px'],
        title: '审核窗口',
        resize: false,
        scrollbar: true,
        content: js.template('importTpl'),
        success: function(layero, index){
            layero.find('input[type="checkbox"]').iCheck();
        },
        btn: ['<i class="fa fa-check"></i> 确认',
            '<i class="fa fa-remove"></i> 取消'],
        btn1: function(index, layero){
            var form = {
                inputForm: layero.find('#inputForm')
            };
            layero.find('#check_id').val(id);
            js.ajaxSubmitForm(form.inputForm, function(data){
                js.showMessage(data.message);
                if(data.result == Global.TRUE){
                    js.layer.closeAll();
                }
                page();
            }, "json");
            return true;
        }
    });
}
</script>
<script id="importTpl" type="text/template">//<!--
<form id="inputForm" action="${ctx}/vip/record/checkRecord" method="post" enctype="form-horizontal"
	class="form-horizontal mt20 mb10" style="overflow:auto;max-height:200px;">
  <input id="check_id" name="id" type="hidden"/>
  <div class="row">
    <div class="col-xs-12">
        <div class="form-group">
            <label class="control-label col-xs-4"> <span class="required " aria-required="true">*</span> 审核：<i class="fa icon-question hide"></i></label>
            <div class="col-xs-8">
                <div class="radio col-xs-6" style="padding-top: 3px;">
                     <label><input type="radio" name="reviewerState" value="1">通过</label>
                </div>
                <div class="radio col-xs-6" style="padding-top: 3px;">
                     <label><input type="radio" name="reviewerState"  value="2">拒绝</label>
                </div>
            </div>
         </div>
         <div class="form-group">
            <label class="control-label col-xs-4"> <span class="required " aria-required="true">*</span> 审核意见：<i class="fa icon-question hide"></i></label>
            <div class="col-xs-8">
                <textarea id="remarks" name="remarks" rows="4" maxlength="500" class="form-control "></textarea>
             </div>
         </div>
   </div>
  </div>
</form>
//--></script>